export class MatrixCache extends Array {
    constructor(public width?: number) {
        super();
    }
    has(x: number, y: number) {
        return this[y * (this.width ?? 0) + x] === 1;
    }
    set(x: number, y: number) {
        this[y * (this.width ?? 0) + x] = 1;
    }
    clear(width?: number) {
        this.length = 0;
        if (width) this.width = width;
    }
}
